package pr;

import org.junit.Before;
import pr.codegen.PrPathesConstant;
import pr.codegen.util.EntityInfoUtilForPR;
import org.junit.Test;

import java.util.Arrays;


public class PrGenCode {
    private PrPathesConstant pathesConstantForPrTask;
    private PrPathesConstant pathesConstantForPrReport;
    String[] tableNames = {
//            "view_hotel_brand_month"
//            "view_brand_grade_brandtype_month"
//            "view_hotel_rank_month"
//            "view_brand_statistics_year"
//            "view_brand_base"
//            "view_brand_history"
            "view_brand_competiter"
    };

    @Before
    public void bef() {

        String packageName = "com.pr.task";
        String businessName = "hotel";
        String rootPath = "/Users/manzhou/Desktop/code/gitee/plusham-data/pr-task/src/main/java/com/pr/task";
        String fileTmpPath = "vms/prtask";
        pathesConstantForPrTask = new PrPathesConstant(packageName, businessName, rootPath, fileTmpPath);


        pathesConstantForPrReport = new PrPathesConstant(
                "com.pr",
                "report",
                "/Users/manzhou/Desktop/code/gitee/plusham-data/pr-estate/src/main/java/com/pr",
                "vms/prreport"
        );
        pathesConstantForPrReport.genService = false;
        pathesConstantForPrReport.domaainPackage = "com.pr.report.domain.researchReport";
        pathesConstantForPrReport.domainPath = "/Users/manzhou/Desktop/code/gitee/plusham-data/pr-api/pr-domain-data/src/main/java/com/pr/report/domain/researchReport";
    }

    /**
     * 注意所有的文件生成路径相关配置在： {@link PrPathesConstant}
     */
    @Test
    public void genTaskCode() {
        Arrays.stream(tableNames).forEach(tableName -> {
            EntityInfoUtilForPR.generatorCodeToDisk(tableName, pathesConstantForPrTask);
        });
    }

    @Test
    public void genReportCode() {
        Arrays.stream(tableNames).forEach(tableName -> {
            EntityInfoUtilForPR.generatorCodeToDisk(tableName, pathesConstantForPrReport);
        });
    }

    /**
     * 注意所有的文件生成路径相关配置在： {@link PrPathesConstant}
     */
    @Test
    public void genSetter() {
        Arrays.stream(tableNames).forEach(tableName -> {
            EntityInfoUtilForPR.generatorCodeToClipboard(tableName, pathesConstantForPrTask);
        });
    }

}